package cn.bigcontainer.alt.meta.controller;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.SessionAttributes;

import cn.bigcontainer.alt.common.exception.BigResultCode;
import cn.bigcontainer.alt.common.util.BigConstant;
import cn.bigcontainer.alt.meta.dto.MAppDto;
import cn.bigcontainer.alt.meta.service.ObjectInputorService;

/**
 * 
 * @author jiaod
 *
 */
@Controller
@RequestMapping("/meta/objectinputor")
@SessionAttributes(BigConstant.SESSION_USER)
public class ObjectInputorController {

	@Resource
	private ObjectInputorService objectInputorService;
	
	/**
	 * @param app
	 * @param propertyId
	 * @param searchContent
	 * @return
	 */
	@RequestMapping("/list")
    @ResponseBody
    public BigResultCode list (MAppDto app, String propertyId, String searchContent) {
		List<Map<String, Object>> list = objectInputorService.list (app.getId(), propertyId, searchContent);
        return BigResultCode.getSuccessCode().setContent(list);
    }
	
	/**
	 * @param app
	 * @param propertyId
	 * @param keyValue
	 * @return
	 */
	@RequestMapping("/value")
    @ResponseBody
    public BigResultCode getValue (MAppDto app, String propertyId, String keyValue, String value) {
		List<Map<String, Object>> values = objectInputorService.getValue (app.getId(), propertyId, keyValue, value);
        return BigResultCode.getSuccessCode().setContent(values);
    }
	
}
